package pl.edu.agh.mguesser.game;

import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import pl.edu.agh.mguesser.playlist.parser.M3UPlaylistParser;
import pl.edu.agh.mguesser.user.User;

/**
 * @author keiran
 */
public class GameSettingsBuilder {
    
    private Path playlist;
    private int rounds;
    private Set<Options> options;
    private List<User> users;

    public GameSettingsBuilder() {
    }

    public void setPlaylist(Path playlist) {
        this.playlist = playlist;
    }

    public void setRounds(int rounds) {
        this.rounds = rounds;
    }

    public void setOptions(Set<Options> options) {
        this.options = options;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }
    
    public GameSettings build() throws GameSettingsBuilderException {
        GameSettings result = new GameSettings();
        
        try {
            result.setPlaylist(new M3UPlaylistParser().parse(playlist));
            
        } catch(Exception ex) {
            throw new GameSettingsBuilderException(ex);
            
        }
        
        result.setRounds(rounds);
        result.setOptions(options);
        result.setUsers(users);
        
        return result;
    }

}
